package com.ln.dm1107.demo01;

import java.time.DayOfWeek;
import java.time.LocalDate;
import java.time.LocalTime;
import java.time.Month;
import java.time.chrono.IsoChronology;

/**
 * @author Ln
 * @version 终极版
 * @date 2022/11/7 15:27
 */
public class Test01 {
    public static void main(String[] args) {
        //自定义时间日期
        LocalDate date = LocalDate.of(2021, 11, 7);
        int dayOfYear1 = date.getDayOfYear();
        System.out.println(dayOfYear1);
        //获取当前日期
        LocalDate now = LocalDate.now();
        System.out.println(date);
        System.out.println(now);
        //年
        int year = now.getYear();
        System.out.println(year);
        //月
        Month month = now.getMonth();
        System.out.println(month.getValue());
        //日
        int dayOfMonth = now.getDayOfMonth();
        System.out.println(dayOfMonth);
        //星期
        DayOfWeek dayOfWeek = now.getDayOfWeek();
        System.out.println(dayOfWeek.getValue());
        //获取当前日期在这一年中是第几天
        int dayOfYear = now.getDayOfYear();
        System.out.println(dayOfYear);


        //自定义时间
        LocalTime of = LocalTime.of(14, 31, 22);
        //获取当前时间
        LocalTime now1 = LocalTime.now();
        System.out.println(of);
        System.out.println(now1);

        int hour = now1.getHour();
        int minute = now1.getMinute();
        int second = now1.getSecond();
        System.out.println(hour);
        System.out.println(minute);
        System.out.println(second);
    }
}
